<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.4"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Flow: flow::log::Ostream_log_msg_writer Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">Flow<span id="projectnumber">&#160;2.0.0</span>
   </div>
   <div id="projectbrief">Flow project: Public API.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.4 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespaceflow.html">flow</a></li><li class="navelem"><a class="el" href="namespaceflow_1_1log.html">log</a></li><li class="navelem"><a class="el" href="classflow_1_1log_1_1Ostream__log__msg__writer.html">Ostream_log_msg_writer</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="classflow_1_1log_1_1Ostream__log__msg__writer-members.html">List of all members</a>  </div>
  <div class="headertitle"><div class="title">flow::log::Ostream_log_msg_writer Class Reference</div></div>
</div><!--header-->
<div class="contents">

<p>Utility class, each object of which wraps a given <code>ostream</code> and outputs discrete messages to it adorned with time stamps and other formatting such as separating newlines.  
 <a href="classflow_1_1log_1_1Ostream__log__msg__writer.html#details">More...</a></p>

<p><code>#include &lt;ostream_log_msg_writer.hpp&gt;</code></p>

<p>Inherits boost::noncopyable.</p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-methods" name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a701b932c4f46f1edb96a975ad7076ccf"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classflow_1_1log_1_1Ostream__log__msg__writer.html#a701b932c4f46f1edb96a975ad7076ccf">Ostream_log_msg_writer</a> (const <a class="el" href="classflow_1_1log_1_1Config.html">Config</a> &amp;config, std::ostream &amp;os)</td></tr>
<tr class="memdesc:a701b932c4f46f1edb96a975ad7076ccf"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructs object wrapping the given <code>ostream</code>.  <a href="classflow_1_1log_1_1Ostream__log__msg__writer.html#a701b932c4f46f1edb96a975ad7076ccf">More...</a><br /></td></tr>
<tr class="separator:a701b932c4f46f1edb96a975ad7076ccf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa05b822916ceb37db219ec73563b146d"><td class="memItemLeft" align="right" valign="top"><a id="aa05b822916ceb37db219ec73563b146d" name="aa05b822916ceb37db219ec73563b146d"></a>
&#160;</td><td class="memItemRight" valign="bottom"><b>~Ostream_log_msg_writer</b> () noexcept</td></tr>
<tr class="memdesc:aa05b822916ceb37db219ec73563b146d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Restores formatting state of <code>os</code> to how it was before entry to constructor. <br /></td></tr>
<tr class="separator:aa05b822916ceb37db219ec73563b146d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aba0a94e36e435aeb67bbc25fee8380f7"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classflow_1_1log_1_1Ostream__log__msg__writer.html#aba0a94e36e435aeb67bbc25fee8380f7">log</a> (const <a class="el" href="structflow_1_1log_1_1Msg__metadata.html">Msg_metadata</a> &amp;metadata, <a class="el" href="namespaceflow_1_1util.html#ae4dc52186797094b3040379ff19124c9">util::String_view</a> msg)</td></tr>
<tr class="memdesc:aba0a94e36e435aeb67bbc25fee8380f7"><td class="mdescLeft">&#160;</td><td class="mdescRight">Logs to the wrapped <code>ostream</code> the given message and associated metadata like severity and time stamp; plus a newline.  <a href="classflow_1_1log_1_1Ostream__log__msg__writer.html#aba0a94e36e435aeb67bbc25fee8380f7">More...</a><br /></td></tr>
<tr class="separator:aba0a94e36e435aeb67bbc25fee8380f7"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p >Utility class, each object of which wraps a given <code>ostream</code> and outputs discrete messages to it adorned with time stamps and other formatting such as separating newlines. </p>
<p >A <a class="el" href="classflow_1_1log_1_1Config.html" title="Class used to configure the filtering and logging behavior of Loggers; its use in your custom Loggers...">Config</a> object controls certain aspects of its behavior; pass this to the constructor. The <a class="el" href="classflow_1_1log_1_1Config.html" title="Class used to configure the filtering and logging behavior of Loggers; its use in your custom Loggers...">Config</a> may come from the user as passed to the <a class="el" href="classflow_1_1log_1_1Logger.html" title="Interface that the user should implement, passing the implementing Logger into logging classes (Flow&#39;...">Logger</a> (if any) using <code>*this</code>; or that <a class="el" href="classflow_1_1log_1_1Logger.html" title="Interface that the user should implement, passing the implementing Logger into logging classes (Flow&#39;...">Logger</a> (if any) can make its own from scratch.</p>
<p >It is assumed that between the first and last calls to <a class="el" href="classflow_1_1log_1_1Ostream__log__msg__writer.html#aba0a94e36e435aeb67bbc25fee8380f7" title="Logs to the wrapped ostream the given message and associated metadata like severity and time stamp; p...">log()</a> no other code whatsoever writes to the underlying stream (as passed to ctor) at any point &ndash; including any formatters. At <code>*this</code> destruction formatter state is restored.</p>
<h3>Rationale</h3>
<p >This optional (but recommended for most <a class="el" href="classflow_1_1log_1_1Logger.html" title="Interface that the user should implement, passing the implementing Logger into logging classes (Flow&#39;...">Logger</a> implementations, though technically not limited to their use) utility class typically sits between some "physical" output medium &ndash; a buffer in memory, a file, etc. &ndash; that can be written to using an <code>ostream</code> (e.g., <code>std::ostringstream</code>, <a class="el" href="classflow_1_1util_1_1String__ostream.html" title="Similar to ostringstream but allows fast read-only access directly into the std::string being written...">util::String_ostream</a>, <code>std::ofstream</code>); and a <a class="el" href="classflow_1_1log_1_1Logger.html" title="Interface that the user should implement, passing the implementing Logger into logging classes (Flow&#39;...">Logger</a> implementation that promises to output log messages to that output medium. When <a class="el" href="classflow_1_1log_1_1Logger.html#a934667f16dd6ca0841e521296ab3a6e2" title="Given a message and its severity, logs that message and possibly severity WITHOUT checking whether it...">Logger::do_log()</a> is called, the message string passed to it will contain the user's original message plus various <a class="el" href="structflow_1_1log_1_1Msg__metadata.html" title="Simple data store containing all of the information generated at every logging call site by flow::log...">Msg_metadata</a> nuggets (like time stamp, severity, source code location) either generated by <a class="el" href="log_8hpp.html#a5daa2b6d16edea74bb8bddc75f7fb801" title="Identical to FLOW_LOG_WITH_CHECKING() but foregoes the filter (Logger::should_log()) check.">FLOW_LOG_WITHOUT_CHECKING()</a> implementation or provided by user. The idea is the <a class="el" href="classflow_1_1log_1_1Logger.html" title="Interface that the user should implement, passing the implementing Logger into logging classes (Flow&#39;...">Logger</a> is to decide on the output format of the various metadata plus the message. Therefore, the present class outputs all those pieces (as appropriate) plus separating newlines. Any <a class="el" href="classflow_1_1log_1_1Logger.html" title="Interface that the user should implement, passing the implementing Logger into logging classes (Flow&#39;...">Logger</a> is free to use any format it wants; and some <code><a class="el" href="classflow_1_1log_1_1Logger.html" title="Interface that the user should implement, passing the implementing Logger into logging classes (Flow&#39;...">Logger</a></code>s might not even generate any output character stream but rather forward everything elsewhere (maybe even over the network); but <a class="el" href="classflow_1_1log_1_1Ostream__log__msg__writer.html" title="Utility class, each object of which wraps a given ostream and outputs discrete messages to it adorned...">Ostream_log_msg_writer</a> provides a reasonable output format to a character stream, to be used or not as desired.</p>
<h3>Thread safety</h3>
<p >For a given <code>*this</code>, the class is not safe for concurrent calls to <a class="el" href="classflow_1_1log_1_1Ostream__log__msg__writer.html#aba0a94e36e435aeb67bbc25fee8380f7" title="Logs to the wrapped ostream the given message and associated metadata like severity and time stamp; p...">log()</a>. The using code must provide any such guarantees.</p>
<p >See thread safety notes and to-dos regarding config in <a class="el" href="classflow_1_1log_1_1Simple__ostream__logger.html" title="An implementation of Logger that logs messages to the given ostreams (e.g., cout or an ofstream for a...">Simple_ostream_logger</a> doc header. These apply here also. </p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a701b932c4f46f1edb96a975ad7076ccf" name="a701b932c4f46f1edb96a975ad7076ccf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a701b932c4f46f1edb96a975ad7076ccf">&#9670;&nbsp;</a></span>Ostream_log_msg_writer()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">flow::log::Ostream_log_msg_writer::Ostream_log_msg_writer </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classflow_1_1log_1_1Config.html">Config</a> &amp;&#160;</td>
          <td class="paramname"><em>config</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::ostream &amp;&#160;</td>
          <td class="paramname"><em>os</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">explicit</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Constructs object wrapping the given <code>ostream</code>. </p>
<p >Does not write any characters to stream (so, for instance, if it happens to be an <code>ofstream</code> then it is fine if it's not yet open or even associated with a path). It may however do stateful things such as format setting.</p>
<p >If any non-default formatting has been applied to <code>os</code>, subsequent behavior is undefined.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">config</td><td>Controls behavior of <code>*this</code>. See thread safety notes in class doc header. This is saved <em>by reference</em> inside <code>*this</code>; it must remain valid through the last <a class="el" href="classflow_1_1log_1_1Ostream__log__msg__writer.html#aba0a94e36e435aeb67bbc25fee8380f7" title="Logs to the wrapped ostream the given message and associated metadata like severity and time stamp; p...">log()</a> call. </td></tr>
    <tr><td class="paramname">os</td><td>Stream to which to write subsequently via <a class="el" href="classflow_1_1log_1_1Ostream__log__msg__writer.html#aba0a94e36e435aeb67bbc25fee8380f7" title="Logs to the wrapped ostream the given message and associated metadata like severity and time stamp; p...">log()</a>. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="aba0a94e36e435aeb67bbc25fee8380f7" name="aba0a94e36e435aeb67bbc25fee8380f7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aba0a94e36e435aeb67bbc25fee8380f7">&#9670;&nbsp;</a></span>log()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void flow::log::Ostream_log_msg_writer::log </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="structflow_1_1log_1_1Msg__metadata.html">Msg_metadata</a> &amp;&#160;</td>
          <td class="paramname"><em>metadata</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="namespaceflow_1_1util.html#ae4dc52186797094b3040379ff19124c9">util::String_view</a>&#160;</td>
          <td class="paramname"><em>msg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Logs to the wrapped <code>ostream</code> the given message and associated metadata like severity and time stamp; plus a newline. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">metadata</td><td>See <code>*metadata</code> in <a class="el" href="classflow_1_1log_1_1Logger.html#a934667f16dd6ca0841e521296ab3a6e2" title="Given a message and its severity, logs that message and possibly severity WITHOUT checking whether it...">Logger::do_log()</a>. </td></tr>
    <tr><td class="paramname">msg</td><td>The message. No terminating newline is assumed (though there is no rule against it; but if one is present, a blank line will appear in wrapped <code>ostream</code>). </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>log/<a class="el" href="ostream__log__msg__writer_8hpp.html">ostream_log_msg_writer.hpp</a></li>
<li>log/<a class="el" href="ostream__log__msg__writer_8cpp.html">ostream_log_msg_writer.cpp</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Mar 28 2025 22:55:32 for Flow by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.4
</small></address>
</body>
</html>
